package thread;

class Test{
    public int value = 0;
}


public class Demo10 {

    private static boolean isFinished = false;

    public static void main(String[] args) throws InterruptedException {
        Test test = new Test();

        Thread t = new Thread(()->{
            while (!isFinished){
                System.out.println("hello thread");
                System.out.println(test.value);
                test.value++;
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println(test.value);
            //test.value++;
            System.out.println("thread end");
            //System.out.println(test.value);
            //test.value ++;
        });

        t.start();

        Thread.sleep(5000);
        isFinished = true;
    }
}
